#!/bin/bash

set -e

echo "=== 修复清华 ROS 404 错误 ==="

# 1. 检查是否是 Ubuntu/Debian
if [ ! -f /etc/os-release ]; then
    echo "错误：仅支持 Ubuntu/Debian 系统"
    exit 1
fi

# 2. 移除无效的 ROS 仓库
echo "移除清华 ROS 仓库..."
sudo rm -f /etc/apt/sources.list.d/ros-latest.list 2>/dev/null || true
sudo sed -i '/mirrors.tuna.tsinghua.edu.cn\/ros\/ubuntu/d' /etc/apt/sources.list 2>/dev/null || true

# 3. 更新软件包列表
echo "更新软件包列表..."
sudo apt update

echo "✅ 修复完成！"